package com.yr.ryjk.redis;

import java.util.Map;

import com.yr.ryjk.common.Constant;

import redis.clients.jedis.Jedis;
/**
 * 获取jedis实例
 * @author Rick
 *
 */
public class RedisFactory {
	private static final String host = "127.0.0.1";
	private static final int port = 6379;
//	private static final String password = "111111";
	
	private static Jedis jedis;

	static{
		jedis=new Jedis(host,port);
//		jedis.auth(password);
	}
	
	public static Jedis getJedis() {
		if(!jedis.isConnected()){
			jedis=new Jedis(host,port);
		}
		return jedis;
	}
	public static void main(String[] args) {
//		jedis.hsetnx("testMap", "aaa", "rickaaa");
		System.out.println(jedis.hget("testMap", "aaa"));
		jedis.hdel("testMap", "aaa");
		
		Map<String, String> map=jedis.hgetAll(Constant.redis_consult_timer_key);
		System.out.println(map.toString());
		
		jedis.del(Constant.redis_consult_timer_key);
	}
}